/***************************************************************************
创建者：华磊
 开始时间：               : 2020.1１.09
 copyright            : (C) 深圳市华友高科有限公司
 修改说明：（每次有修改就添加一条，带有 修改人，修改时间，修改描述）

 ***************************************************************************
 *   底部视窗对话框
*                                                                         *
 ***************************************************************************/
#include "bottomview.h"
#include "ui_bottomview.h"

BottomView::BottomView(int styleId,QWidget *parent) :
    QWidget(parent),
    ui(new Ui::BottomView)
{
    ui->setupUi(this);

    setGeometry(rect().x()+70, rect().y()+720,460, 80);
    initialDisplayStyle(styleId);

    globalPicPath = "/agvwork/AgvHmi/baseBag/hmiProject/resources/bottomviewresources/";

    initBottomPicFLag = false;

    runProgramCheckDialog = new RunProgramCheckDialog;
    //0000
}

BottomView::~BottomView()
{
    delete ui;
}

void BottomView::initialDisplayStyle(int styleId)
{
    switch (styleId) {
    case 1:
        ui->RunBtn->setGeometry(30,30,65,45);
        ui->StopBtn->setGeometry(150-1,30,65,45);
        ui->PauseBtn->setGeometry(270-1,30,65,45);
        ui->ZeroBtn->setGeometry(390-1,30,65,45);
        ui->returnBtn->setGeometry(510-1,30,65,45);

        break;
    default:
        break;
    }
}
void BottomView::updateView()
{
    if(initBottomPicFLag)//初始化完成后,只对运行,停止,暂停的图片作修改
    {
        ui->RunBtn->setStyleSheet(QString("border-image: url(%1);").arg(button1PictureAddress));

        ui->StopBtn->setStyleSheet(QString("border-image: url(%1);").arg(button2PictureAddress));

        ui->PauseBtn->setStyleSheet(QString("border-image: url(%1);").arg(button3PictureAddress));
    }
    else
    {
        ui->RunBtn->setStyleSheet(QString("border-image: url(%1);").arg(button1PictureAddress));

        ui->StopBtn->setStyleSheet(QString("border-image: url(%1);").arg(button2PictureAddress));

        ui->PauseBtn->setStyleSheet(QString("border-image: url(%1);").arg(button3PictureAddress));

        ui->ZeroBtn->setStyleSheet(QString("border-image: url(%1);").arg(button4PictureAddress));

        ui->returnBtn->setStyleSheet(QString("border-image: url(%1);").arg(button5PictureAddress));

        initBottomPicFLag = true;
    }
}

void BottomView::on_RunBtn_pressed()
{
    emit button1Signal();
}

void BottomView::on_RunBtn_released()
{
    emit buttonDebugStopSignal();
}

void BottomView::on_StopBtn_clicked()
{
    emit button2Signal();
}

void BottomView::on_PauseBtn_clicked()
{
    emit button3Signal();
}

void BottomView::on_ZeroBtn_clicked()
{
    emit button4Signal();
}

void BottomView::on_returnBtn_clicked()
{
    emit button5Signal();
}

void BottomView::changeLanguage(int language)
{
    if(1 == language)
    {
        translator.load("/agvwork/AgvHmi/baseBag/hmiProject/language/bottomViewEnglishLan.qm");
        qApp->installTranslator(&translator);
    }
    else
    {
        qApp->removeTranslator(&translator);
    }
    ui->retranslateUi(this);
    runProgramCheckDialog->changeLanguage();
}
